| MATLAB Function Reference | ![]() |
Load workspace variables from disk
Syntax
load loadfilenameloadfilename X Y Zload filename -asciiload filename -matS = load(...)
Description
load loads all the
variables from the MAT-file matlab.mat, if it exists, and returns
an error if it doesn't exist.
load filename loads all
the variables from filename given a full pathname or a
MATLABPATH relative partial pathname. If filename has
no extension, load looks for file named filename or
filename.mat and treats it as a binary MAT-file. If
filename has an extension other than .mat,
load treats the file as ASCII data.
load filename X Y Z ... loads just the specified variables from the MAT-file. The
wildcard '*' loads variables that match a pattern (MAT-file only).
forces
load -ascii filename
or load -mat filename load to treat the file as either an ASCII file or a MAT-file,
regardless of file extension. With -ascii, load
returns an error if the file is not numeric text. With -mat,
load returns an error if the file is not a MAT-file.
load -ascii filename
returns all the data in the file as a single two dimensional double array
with its name taken from the filename (minus any extension). The number of rows
is equal to the number of lines in the file and the number of columns is equal
to the number of values on a line. An error occurs if the number of values
differs between any two rows.
reads ASCII files that contain rows of space-separated values.
The resulting data is placed into a variable with the same name as the file
(without the extension). ASCII files may contain MATLAB comments (lines that
begin with load filename.ext %).
If filename is a MAT-file, load
creates the requested variables from filename in the workspace. If
filename is not a MAT-file, load creates a double precision array
with a name based on filename. load replaces leading underscores or
digits in filename with an X and replaces other
non-alphabetic character with underscores. The text file must be organized as a
rectangular table of numbers, separated by blanks, with one row per line, and an
equal number of elements in each row.
S = load(...) returns
the contents of a MAT-file in the variable S. If the file is a
MAT-file, S is a struct containing fields that match the variables
in retrieved. When the file contains ASCII data,
S is a double-precision array.
Use the functional form of load, such as
load('filename'), when the file name is stored in a string, when an
output argument is requested, or if filename contains spaces. To
specify a command line option with this functional form, specify the option as a
string argument, including the hyphen. For example,
load('myfile.dat','-mat')
Remarks
MAT-files are double-precision binary MATLAB format files
created by the save command
and readable by the load command. They can be created on one
machine and later read by MATLAB on another machine with a different
floating-point format, retaining as much accuracy and range as the disparate
formats allow. They can also be manipulated by other programs, external to
MATLAB.
The Application Program Interface Libraries contain C- and Fortran-callable routines to read and write MAT-files from external programs.
See Also
fprintf,
fscanf,
partialpath,
save,
spconvert
|
listdlg | load (activex) | ![]() |